package stock

import (
	"context"

	"gitee.com/lyuanbo/stock-plus/pkg/logger"
	"gitee.com/lyuanbo/stock-plus/pkg/stock/exchange"
	"gitee.com/lyuanbo/stock-plus/pkg/stock/tencent"
	"gitee.com/lyuanbo/stock-plus/pkg/stock/xueqiu"
	"github.com/nats-io/nats.go"
	"github.com/redis/go-redis/v9"
)

type Stock struct {
	XueQiu   *xueqiu.XueQiu
	Tencent  *tencent.Tencent
	Exchange *exchange.DynamicExchange
}

func New(ctx context.Context, nats *nats.Conn, redis *redis.Client, logger *logger.Logger) *Stock {
	xq := xueqiu.New(ctx, redis, logger)

	ex := exchange.New(logger, xq)
	xq.SetExchange(ex)

	s := &Stock{
		XueQiu:  xq,
		Tencent: tencent.New(ctx, ex, xq, nats, redis, logger),
	}

	return s
}
